﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RastinArgham.CRM.Business;

namespace RastinArgham.CRM.Web
{
    public partial class ContactInfo : System.Web.UI.UserControl
    {
        public Contact contact { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {            
        }

        protected override void DataBind(bool raiseOnDataBinding)
        {
            if (contact != null)
            {
                lblContactTitle.Text = contact.ContactTitle;
                lblPhone.Text = contact.MobilePhone;
                lblCity.Text = contact.CityName;
                hlEditContact.NavigateUrl = contact.EditLink;
                hlEditProducts.NavigateUrl = contact.ProductsLink;
                hlEditServices.NavigateUrl = contact.ServicesLink;
            }

 	        base.DataBind(raiseOnDataBinding);
        }

        protected void lbDownloadPhotos_Click(object sender, EventArgs e)
        {
            if (contact == null && String.IsNullOrEmpty(Request.QueryString["id"])) {
                return;
            } 

            string path = ImageExport.Export(Convert.ToInt32(Request.QueryString["id"]), "~/tmp/", true, true);
            Response.Redirect(path);
        }
    }
}